package com.xxxx.seckill.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ClassName: RespBean
 * @Title: seckill
 * @Package: com.xxxx.seckill.vo
 * @Description: 公共返回对象
 * @Author: Kisen
 * @Date: 2021/3/4 22:29
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RespBean {

    private long code;
    private String message;
    private Object obj;

    /**
     * 成功返回结果
     * @return
     */
    public static RespBean success() {
        return new RespBean(RespBeanEnum.SUCCES.getCode(),RespBeanEnum.SUCCES.getMessage(),null);
    }

    public static RespBean success(Object obj) {
        return new RespBean(RespBeanEnum.SUCCES.getCode(),RespBeanEnum.SUCCES.getMessage(),obj);
    }

    /**
     * 失败返回结果
     * @param respBeanEnum
     * @return
     */
    public static RespBean error(RespBeanEnum respBeanEnum) {
        return new RespBean(respBeanEnum.getCode(),respBeanEnum.getMessage(),null);
    }

    public static RespBean error(RespBeanEnum respBeanEnum, Object obj) {
        return new RespBean(respBeanEnum.getCode(),respBeanEnum.getMessage(),obj);
    }
}
